home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / unShareBrush.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  2.8 KB  |  82 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Description:
  22. //        This script is executed when a new scene file is created.  It will create
  23. //        panels if required or use existing panels.
  24. //
  25. //  Creation Date: Dec 1998
  26. //  Author:        APP
  27. //
  28. global proc string unShareBrush( )
  29. {
  30.     // No arguments. Takes selection list and makes all strokes
  31.     // which share the same brush use different brushes.
  32.     // Returns the name of the last brush made.
  33.  
  34.     string $nodes[] = `getStrokes 2`;
  35.     string $node;
  36.     string $brushes[];
  37.     int    $bIdx = 0;
  38.  
  39.     if (size( $nodes ) == 0) {
  40.         // No strokes were found, quit.
  41.         warning("No paths are in the selection list to unshare brushes - need multiple paths - no action taken.");
  42.         return "";
  43.     }
  44.     if (size( $nodes ) == 1) {
  45.         // Only one stroke was found, quit.
  46.         warning("Only 1 path is on the selection list to unshare brushes - need multiple paths - no action taken.");
  47.         return "";
  48.     }
  49.     for ($node in $nodes) {
  50.         string $attr = $node + ".brush";
  51.         string $result = `connectionInfo -sfd $attr`;
  52.         string $buffer[];
  53.         int $num = `tokenize $result "." $buffer`;
  54.         $brushes[ $bIdx ] = $buffer[0];
  55.         ++$bIdx;
  56.     }
  57.  
  58.     // Loop over the nodes in the strokes brushes list and any that have duplicates, create a new brush, and attach.
  59.     $i = 0;
  60.     string $createdBrush = "";
  61.     while ($i < $bIdx) {
  62.         // Get the current brush.
  63.         string $target = $brushes[$i];
  64.         int $j = $i + 1;
  65.         // Now look through the rest of the brushes looking for a brush of the same name.
  66.         while ($j < $bIdx) {
  67.             if ($brushes[$j] == $target) {
  68.                 // We found a duplicate. Duplicate the $target brush and reconnect the appropriate node.
  69.                 string $newBrush[] = `duplicate -ic $target`;
  70.                 string $attrDst = $nodes[ $j ] + ".brush";
  71.                 string $attrSrc = $newBrush[0] + ".outBrush";
  72.                 connectAttr -f $attrSrc $attrDst;
  73.                 $j = $bIdx; // break out of this inner loop
  74.             }
  75.             $j = $j + 1;
  76.         }
  77.         $i = $i + 1;
  78.     }
  79.     
  80.     return $createdBrush;
  81. }
  82.